﻿using System;
using System.Collections.Generic;
using Storage.Core;

namespace Storage.Server
{
	internal static class StorageServerEntryPoint
	{
		public static void Main(string[] args)
		{
			var settings = StorageSettings.GetInstance();
			LogStart(settings);

			Dictionary<string, Scope> scopes;
			Dictionary<Guid, PlainEntity> entities;

			using (var olParser = new StorageOperationLogParser())
				olParser.Parse(out entities, out scopes);
			var storage = new ScopeBasedStorage(entities, scopes, new StorageOperationLog());
			var server = new StorageServer(storage, settings.Address, settings.Port);
			server.Start();
		}

		private static void LogStart(StorageSettings settings)
		{
			Console.Out.WriteLine("StorageServer. Starting on endpoint: {0}:{1}", settings.Address, settings.Port);
		}
	}
}
